package com.example.demo.service.impl;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.entity.PageUtil;
import com.example.demo.entity.User;
import com.example.demo.mapper.Demo5Mapper;
import com.example.demo.service.Demo5Service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 港某
 * @date 2021/9/14 11:11
 */
@Slf4j
@Service
public class Demo5ServiceImpl extends ServiceImpl<Demo5Mapper, Object> implements Demo5Service {


    @Override
    public PageUtil<User> getUsers(int limit, int page) {
        Page<User> p = new Page<>(page, limit);
        List<User> users = baseMapper.getUsers(p);
        p.setRecords(users);
        return new PageUtil<>(p);
    }

    @Override
    public void addUser(User user) {
        baseMapper.insertUser(user);
    }

    @Override
    public List<User> getUsers(String[] ids) {
        return baseMapper.getUsersByIds(ids);
    }


}
